<template>
    <div>
        <div class="mj-manage-on">
            <div class="top-info">
                <div class="left">全店满减券（{{cates.length}}）</div>
                <div class="right">
                    <router-link :to="{name:'Business_add_mj'}">
                        新增
                    </router-link>
                </div>
            </div>
            <div class="bottom-info">
                <div class="tips-info">
                    <i class="icon"></i>
                    <span class="text">特价商品不参与全店满减{{cates.reach1}}</span>
                </div>
                <ul class="list-ul">
                    <li class="list-li" v-for="shuzu in cates" :key="shuzu.id">
                        <div class="left">
                            <span class="price" v-show="false">
                                <span>￥</span>{{shuzu.score1 |amountMin100(2)}}
                            </span>
                            <span class="price1">满{{shuzu.reach1 |amountMin100(2)}}减 {{shuzu.score1 |amountMin100(2)}}</span>
                        </div>
                        <a class="delete" @click="delcate(shuzu.id)">删除</a>
                    </li>
                </ul>
            </div>
        </div>
        <business_footer :pageName="'busiManjian'"></business_footer>
    </div>
</template>
<style scoped>
    @import "../../../assets/business/css/mj_manage.css";
</style>
<script>
    import business_footer from "@/components/business_footer"
    export default {
        data() {
            return {
                cates: [],
                comID: 0
            }
        },
        methods: {
            loadcates: function () {
                this.$http.get(this.APIURL_PREFIX + '/api/wap/coupon').then((response) => {
                    console.log(response.data)
                    this.cates = response.data.data;
                    console.log(this.cates)
                }).catch(function (err) {
                    console.log(err)
                });
            },
            delcate: function (id) {
                var vm=this;
                layer.confirm('确定要删除该优惠券吗？', {
                    btn : [ '确定', '取消' ]//按钮
                }, function() {
                    vm.$http.delete(vm.APIURL_PREFIX + '/api/wap/coupon/' + id).then((response) => {
                        vm.cates = vm.cates.filter(function (item) { console.log(id == item.id); return id != item.id });
                         layer.msg("删除成功")
                    }).catch(function (err) {
                        layer.msg("删除失败");
                        console.log(err)
                    });
                }); 
            }
        },
        mounted() {
            this.loadcates()
        },
        components: {
            business_footer
        }
    }
</script>
